using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_Province {
		#region Fields
		private int iD;
		private int provinceID;
		private string provice_Name;
		private int countryID;
		private int languageID;
		private int isSameCity;
		private string locCode;
		private string name;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_Province class.
		/// </summary>
		public TF_Province() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Province class.
		/// </summary>
		public TF_Province(int provinceID, string provice_Name, int countryID, int languageID, int isSameCity, string locCode, string name) {
			this.provinceID = provinceID;
			this.provice_Name = provice_Name;
			this.countryID = countryID;
			this.languageID = languageID;
			this.isSameCity = isSameCity;
			this.locCode = locCode;
			this.name = name;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_Province class.
		/// </summary>
		public TF_Province(int iD, int provinceID, string provice_Name, int countryID, int languageID, int isSameCity, string locCode, string name) {
			this.iD = iD;
			this.provinceID = provinceID;
			this.provice_Name = provice_Name;
			this.countryID = countryID;
			this.languageID = languageID;
			this.isSameCity = isSameCity;
			this.locCode = locCode;
			this.name = name;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the ID value.
		/// </summary>
		public int ID {
			get { return iD; }
			set { iD = value; }
		}
		
		/// <summary>
		/// Gets or sets the ProvinceID value.
		/// </summary>
		public int ProvinceID {
			get { return provinceID; }
			set { provinceID = value; }
		}
		
		/// <summary>
		/// Gets or sets the Provice_Name value.
		/// </summary>
		public string Provice_Name {
			get { return provice_Name; }
			set { provice_Name = value; }
		}
		
		/// <summary>
		/// Gets or sets the CountryID value.
		/// </summary>
		public int CountryID {
			get { return countryID; }
			set { countryID = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanguageID value.
		/// </summary>
		public int LanguageID {
			get { return languageID; }
			set { languageID = value; }
		}
		
		/// <summary>
		/// Gets or sets the IsSameCity value.
		/// </summary>
		public int IsSameCity {
			get { return isSameCity; }
			set { isSameCity = value; }
		}
		
		/// <summary>
		/// Gets or sets the LocCode value.
		/// </summary>
		public string LocCode {
			get { return locCode; }
			set { locCode = value; }
		}
		
		/// <summary>
		/// Gets or sets the Name value.
		/// </summary>
		public string Name {
			get { return name; }
			set { name = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_Province table.
		/// </summary>
		public void Insert() {
			iD = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_ProvinceInsert", provinceID, provice_Name, countryID, languageID, isSameCity, locCode, name));
		}
		
		/// <summary>
		/// Updates a record in the TF_Province table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_ProvinceUpdate", iD, provinceID, provice_Name, countryID, languageID, isSameCity, locCode, name);
		}
		
		/// <summary>
		/// Deletes a record from the TF_Province table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_ProvinceDelete", iD);
		}
		
		/// <summary>
		/// Selects a single record from the TF_Province table.
		/// </summary>
		public static TF_Province Select(int iD) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_ProvinceSelect", iD)) {
				if (dataReader.Read()) {
					return MakeTF_Province(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_Province table.
		/// </summary>
		public static List<TF_Province> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_ProvinceSelectAll")) {
				List<TF_Province> tF_ProvinceList = new List<TF_Province>();
				while (dataReader.Read()) {
					TF_Province tF_Province = MakeTF_Province(dataReader);
					tF_ProvinceList.Add(tF_Province);
				}
				return tF_ProvinceList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_Province class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_Province MakeTF_Province(SqlDataReader dataReader) {
			TF_Province tF_Province = new TF_Province();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_Province.ID = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_Province.ProvinceID = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_Province.Provice_Name = dataReader.GetString(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_Province.CountryID = dataReader.GetInt32(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_Province.LanguageID = dataReader.GetInt32(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_Province.IsSameCity = dataReader.GetInt32(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_Province.LocCode = dataReader.GetString(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_Province.Name = dataReader.GetString(7);
			}

			return tF_Province;
		}
		#endregion
	}
}
